﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Media.Animation;
using System.Windows.Threading;

namespace silder
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
        private void Window_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
        	if (e.LeftButton == MouseButtonState.Pressed)
            {
                RightClickMenu.Visibility = Visibility.Hidden;
                DragMove();                
            }
            else if(e.RightButton==MouseButtonState.Pressed)
			{
                RightClickMenu.Margin = new Thickness(e.GetPosition(this).X, e.GetPosition(this).Y, 0, 0);
                RightClickMenu.Visibility = Visibility.Visible;
			}
			// 在此处添加事件处理程序实现。
        }

        private void Image_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
			this.Close();
			// 在此处添加事件处理程序实现。
        }
        private void Window_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
			ReFreshTime();
			DispatcherTimer timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(1);
            timer.IsEnabled = true;
            timer.Tick += new EventHandler(timer_Tick);
			// 在此处添加事件处理程序实现。
        }

        void timer_Tick(object sender, EventArgs e)
        {
			ReFreshTime();
        }
        void ReFreshTime()
        {
            TimeNow.Text = "";
            //更新当前日期
            TimeNow.Text += DateTime.Now.Hour + ":";
            if (DateTime.Now.Minute < 10)
            {
                TimeNow.Text += "0" + DateTime.Now.Minute;
            }
            else
            {
                TimeNow.Text += DateTime.Now.Minute;
            }
        }
        private void UnLock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            this.Topmost = true;
            Lock.Visibility = Visibility.Visible;
            UnLock.Visibility = Visibility.Hidden;
        }

        private void Lock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            this.Topmost =false;
            Lock.Visibility = Visibility.Hidden;
            UnLock.Visibility = Visibility.Visible;
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            DoubleAnimation an = new DoubleAnimation();
            an.From = 100;
            an.To = 0;
            an.Duration = TimeSpan.FromSeconds(1);
            MainGrid.BeginAnimation(Grid.OpacityProperty, an);
            MainGrid.Background = new ImageBrush(Img2.Source);
            an.From = 0;
            an.To = 100;
            MainGrid.BeginAnimation(Grid.OpacityProperty, an);
            RightClickMenu.Visibility = Visibility.Hidden;
        }

        private void Button_FL_Click(object sender, System.Windows.RoutedEventArgs e)
        {
			DoubleAnimation an = new DoubleAnimation();
            an.From = 100;
            an.To = 0;
            an.Duration = TimeSpan.FromSeconds(1);
            MainGrid.BeginAnimation(Grid.OpacityProperty, an);
            MainGrid.Background = new ImageBrush(Img1.Source);
            an.From = 0;
            an.To = 100;
            MainGrid.BeginAnimation(Grid.OpacityProperty, an);
            RightClickMenu.Visibility = Visibility.Hidden;
        	// 在此处添加事件处理程序实现。
        }

        private void Menu_BL_Click(object sender, System.Windows.RoutedEventArgs e)
        {
						DoubleAnimation an = new DoubleAnimation();
            an.From = 100;
            an.To = 0;
            an.Duration = TimeSpan.FromSeconds(1);
            MainGrid.BeginAnimation(Grid.OpacityProperty, an);
            MainGrid.Background = new ImageBrush(Img3.Source);
            an.From = 0;
            an.To = 100;
            MainGrid.BeginAnimation(Grid.OpacityProperty, an);
            RightClickMenu.Visibility = Visibility.Hidden;
        	// 在此处添加事件处理程序实现。
        }
    }
}
